import apiMixin from '@/mixin/apiMixin';
import taskMixin from '@/mixin/taskMixin';

import uilts from '@/utils/index';
export default {
    mixins: [apiMixin,taskMixin],
    data() {
        return {
            loading: false,
            tableData:[],
            searchTypeList: [
                { value: "task_title", name: "任务标题" },
                { value: "task_id", name: "任务ID" },
                { value: "user_name", name: "用户昵称" },
                { value: "user_id", name: "用户ID" },
                { value: "user_tel", name: "手机号码" },
                { value: "task_accept_id", name: "接单ID" }
            ],
            searchType: 'task_title',
            searchText: '',
            listNumsTotal: 0,
            curPage: 1,
            status: [
                {
                    text: '进行中',
                    value: '1'
                },
                {
                    text: '待审核',
                    value: '2'
                },
                {
                    text: '已完成',
                    value: '3'
                },
                {
                    text: '仲裁中',
                    value: '4'
                },
                {
                    text: '未通过',
                    value: '5'
                },
                {
                    text: '已关闭',
                    value: '6'
                },
            ]
        }
    },
    created() {
        let search = this.$route.query.search;
        if (search) {
            let searchArr = search.split(',');
            let _self = this;
            let slotObj = {
                'taskId': () => {
                    _self.searchType = "task_id";
                    _self.searchText = searchArr[1];
                }
            };
            slotObj[searchArr[0]]();
        }
    },
    mounted() {
        if (this.filterStatus == 0 || this.filterStatu) {
            this.$refs.filterTable.columns[5].filteredValue = this.filterStatus.split(',');
        }
        this.init();
    },
    methods: {
        init() {
            this.getAcceptListApi(this.curPage);
        },
        changePage(page){
            page = page || 1;
            this.getAcceptListApi(page);
        },
        handleSearch() {
            this.curPage = 1;
            this.getAcceptListApi();    
        },
        getAcceptListApi(page) {
            let _self = this;
            this.comResquest(this.request.getAcceptList,(res)=>{
                console.log(res);
                _self.curPage = Number(page || 1);
                _self.updateRoutePar(page);
                let { count,result } = res;
                _self.listNumsTotal = count;
                _self.tableData = result;
            },{
                page: page,
                keyword: this.searchText,
                type: this.searchType,
                load: true,
                status: this.filterStatus
            })
        },
        handleFilter(e) {
            console.log( e.status);
            this.filterStatus = e.status.join(',');
            this.getAcceptListApi(1);
        }
    },
}